//
//  XJ_AccountBook_DetailViewController.m
//  XunJieProject
//
//  Created by xue on 2018/6/7.
//  Copyright © 2018年 Soowin. All rights reserved.
//

#import "XJ_AccountBook_DetailViewController.h"
#import "XJ_DealDetailModel.h"

@interface XJ_AccountBook_DetailViewController ()
@property (weak, nonatomic) IBOutlet ZDXXibLabel *dealTypeLabel;
@property (weak, nonatomic) IBOutlet ZDXXibLabel *dealTypeLabel1;
@property (weak, nonatomic) IBOutlet UIImageView *dealResultLogo;

@property (weak, nonatomic) IBOutlet UILabel *dealMoneyLabel;
@property (weak, nonatomic) IBOutlet UILabel *dealTypeLabel2;
@property (weak, nonatomic) IBOutlet UILabel *dealTimeLabel;
@property (weak, nonatomic) IBOutlet UILabel *flowNoLabel;
@property (weak, nonatomic) IBOutlet UILabel *serviceChargeLabel;
@property (weak, nonatomic) IBOutlet UILabel *cardNoLabel;
@property (weak, nonatomic) IBOutlet UILabel *dealResultDesLabel;
@property (weak, nonatomic) IBOutlet NSLayoutConstraint *up_scrollView;
@property (weak, nonatomic) IBOutlet NSLayoutConstraint *height_contentView;

@end

@implementation XJ_AccountBook_DetailViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view from its nib.
    
    [self loadDealDetail];
}
-(void)creatMainUI{
    
    self.nav_titleLabel.text =@"详情";
    _up_scrollView.constant =SafeAreaTopHeight;
    _height_contentView.constant =SCREEN_HEIGHT-SafeAreaTopHeight;
}

#pragma mark--获取账本明细
-(void)loadDealDetail{
    NSUserDefaults * db = [NSUserDefaults standardUserDefaults];
    NSString * token = [db objectForKey:@"token"];
    
    NSMutableDictionary * dic = [NSMutableDictionary dictionary];
    [dic setValue:IDENTIFIER forKey:@"equipmentNo"];
    [dic setValue:STSTERMVERSION forKey:@"systemVersion"];
    [dic setValue:APPVERSION forKey:@"appVersion"];
    [dic setValue:USERID forKey:@"userId"];
    [dic setValue:token forKey:@"token"];
    
    [dic setValue:@(_dealId) forKey:@"dealId"];
    [XJ_Utils signPost:@"/deal/detail?" parameters:dic success:^(NSInteger recode, id jsonObject) {
        
        
        NSDictionary * dataDic = [jsonObject objectForKey:@"data"];
        
        XJ_DealDetailModel * model = [XJ_DealDetailModel mj_objectWithKeyValues:dataDic];
        self.dealTypeLabel.text =model.dealTypeDes;
        self.dealTypeLabel1.text =model.dealResultDes;
        self.dealTypeLabel2.text =model.dealTypeDes;
        self.dealMoneyLabel.text =model.dealMoney;
        self.dealTimeLabel.text =model.dealTime;
        self.flowNoLabel.text =model.flowNo;
        self.cardNoLabel.text =model.cardNo;
        if (model.serviceCharge.length>0) {
            self.serviceChargeLabel.text =model.serviceCharge;
        }else{
            self.serviceChargeLabel.text =@"0.00";
        }
        
        self.dealResultDesLabel.text =model.dealResultDes;
        ///交易状态 0：失败 1：进行中 2：成功
        if ([model.dealResultType isEqualToString:@"0"]) {
            self.dealResultLogo.image =[UIImage imageNamed:@"fail"];
        }else if ([model.dealResultType isEqualToString:@"1"]){
            self.dealResultLogo.image =[UIImage imageNamed:@"going"];
        }else if ([model.dealResultType isEqualToString:@"2"]){
            self.dealResultLogo.image =[UIImage imageNamed:@"suc"];
        }
     
        
        
        
    } failure:^(NSInteger recode, NSError *error) {
        
    }];
}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
